/**
 * 
 */
package com.sip.comadapter.executor.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.sip.comadapter.common.utils.ApplicationContextUtils;

/**
 * @author Dhanushka Ariyasingha.
 *
 */
public class ExecutorLoadFactory {

	private static ExecutorLoadFactory factory = null;
	
	private ApplicationContext applicationContext = null;
	
	private ExecutorLoadFactory(){
		
		
	    String[] locations=getConfigLocations();
	    applicationContext = new FileSystemXmlApplicationContext(locations);
	    
	
	}
	
	
	public static ExecutorLoadFactory getInstance(){
		
		if(null == factory){
			factory = new ExecutorLoadFactory();
		}
		
		return factory;
	}
	
	public Executor getExecutor(final String executorName){
		
		return (Executor) applicationContext.getBean(executorName);
	}
	
	protected String[] getConfigLocations()
    {

	    
	  return new String[]{"classpath:config/application-context.xml",
        "classpath:config/executor-context.xml"};
    }
}
